Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2kc = require("kc");
var $2KDefine = require("KDefine");
var $2BulletBase = require("BulletBase");
var $2BundleManager = require("BundleManager");
var $2ExcelManager = require("ExcelManager");
var $2DataManager = require("DataManager");
var def_BulletMgr = /* */function () {
  function _ctor() {
    babel_classCallCheck(this, _ctor);
    this.itemPoolSize = 200;
    this.itemNode = null;
    this.bulletPool = new cc.NodePool();
    this.allItemArr = {};
    this.hurtEffectPool = new cc.NodePool();
  }
  babel_createClass(_ctor, [{
    key: "init",
    value: function init() {
      this.itemNode = cc.instantiate($2BundleManager.default.instance.getBundleRes("Prefab", "bullet/bullet_1"));
      this.allItemArr = $2ExcelManager.ExcelMgr.instance.GetExcelObject($2ExcelManager.TableName.bulletTable);
      for (var _e11 = 0; _e11 < this.itemPoolSize; _e11++) {
        this.bulletPool.put(cc.instantiate(this.itemNode));
      }
      for (var _e12 = 0; _e12 < this.itemPoolSize; _e12++) {
        this.hurtEffectPool.put(cc.instantiate($2BundleManager.default.instance.getBundleRes("Prefab", "effect/hurtEffect")));
      }
      return this;
    }
  }, {
    key: "createItem",
    value: function createItem() {
      return cc.instantiate(this.itemNode);
    }
  }, {
    key: "getItem",
    value: function getItem(e, t, a) {
      var i = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
      var o = null;
      if (!(o = this.bulletPool.get())) {
        $2kc.default.log("BulletItemPool is empty");
        o = this.createItem();
      }
      var l = o.getComponent($2BulletBase.default);
      l.reset(t, e, a, i);
      return l;
    }
  }, {
    key: "getEffect",
    value: function getEffect(e) {
      var t = null;
      t = this.hurtEffectPool.get();
      if (!t) {
        t = cc.instantiate($2BundleManager.default.instance.getBundleRes("Prefab", "effect/hurtEffect"));
      }
      t.getComponent(sp.Skeleton).skeletonData = $2BundleManager.default.instance.getBundleRes("Spine", "effect/" + e + "/" + e, sp.SkeletonData);
      t.opacity = 255;
      return t;
    }
  }, {
    key: "removeEffect",
    value: function removeEffect(e) {
      e.getComponent(sp.Skeleton).skeletonData = null;
      this.hurtEffectPool.get(e);
    }
  }, {
    key: "removeBullet",
    value: function removeBullet(e) {
      e.inUse = false;
      cc.Tween.stopAllByTarget(e.node);
      e.node.getChildByName("bulletEffect").active = false;
      if (1 == e.type) {
        e.node.removeComponent(cc.Sprite);
      } else {
        e.node.removeComponent(sp.Skeleton);
      }
      e.node.angle = 0;
      this.bulletPool.put(e.node);
    }
  }, {
    key: "removeFromPool",
    value: function removeFromPool(e) {}
  }], [{
    key: "instance",
    value: function instance() {
      _ctor._me || (_ctor._me = new _ctor());
      return _ctor._me;
    }
  }, {
    key: "shoot_to_right",
    value: function shoot_to_right(e, t, a, n) {
      var s = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
      var o = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 1;
      var l = arguments.length > 6 ? arguments[6] : undefined;
      var d = arguments.length > 7 ? arguments[7] : undefined;
      var h = _ctor.instance().getItem(a, n, l, d);
      var u = h.node;
      u.parent = e;
      u.zIndex = $2KDefine.ZIndex.bullet;
      u.setPosition(t);
      cc.tween(u).call(function () {
        u.opacity = 255;
      }).by((s + 1) * $2DataManager.default.instance.blockWidth / (600 * o), {
        x: (s + 1) * $2DataManager.default.instance.blockWidth
      }).call(function () {
        _ctor.instance().removeBullet(h);
      }).start();
    }
  }]);
  return _ctor;
}();
exports.default = def_BulletMgr;
def_BulletMgr._me = null;